//
//  JoStaticNodeCell.swift
//  soapp
//
//  Created by zhu xietong on 2018/2/14.
//

import Foundation
import Eelay
open class JoStaticNodeCell<KitType:JoTouchNode,Layout:JoNodeLayout>: JoCellNode,EeActionDelegate{
    
    public let listV = JoItemsNode<KitType>()
    open override func addLayoutRules() {
        
        listV.delegate = self
        listV.layoutInfo = Layout.layout
        backgroundColor = .white
    }
    
    open override func specGetter() -> _Spec {
        return .inset([],.zero, child: listV.Spec)
    }
    
    
    open override func mo_model_reload() {
        
        let list = DataNode.path(node: "list",mo.model, value: NSMutableArray())
//        list.listObj { (dict:NSMutableDictionary) in}
//        listV.controller = m
        listV.list = list
    }
    
    open func active(onwer: Any, actionID: String, data: NSMutableDictionary) {
        let kind = listV.layouts["kind","unkown"]
        let index = data["__index","x"]
        self.delegate?.touch(cell: self, actionID: "\(kind)[\(index)]", model: data)
    }}





public protocol JoNodeLayout:class {
    static var layout:TP.layouts{get}
}
open class JoDemoNodeLay:NSObject,JoNodeLayout{
    public static var layout:TP.layouts{
        get{
            let layout:TP.layouts = [
                "kind":"do",
                "frame":"3*2",
                "size_scale":"1",
                "padding":"20|20|20|20",
                "space":"\(TP.separatorHeight)|\(TP.separatorHeight*4)",
                "kits":[
                    ["frame":"0|0|1|1","title":"精品旅游","hex":"#111","type":"order"],
                    ["frame":"1|0|1|1","title":"户外探险","hex":"#222","type":"chat"],
                    ["frame":"2|0|1|1","title":"顶级游","hex":"#333","type":"chat"],
                    ["frame":"0|1|1|1","title":"报团定制","hex":"#444","type":"order"],
                    ["frame":"1|1|2|1","title":"亲子游","hex":"#555","type":"chat"],
                ],
            ]
            return layout
        }
    }
    
}
